<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Skornyakov Anatoliy
 * Date: 30.05.13
 * Time: 14:38
 * 
 */

class Zftest_Form_User extends Zftest_Form
{
    public function init()
    {
        parent::init();

        $this->setAction('')
             ->setMethod(Zend_Form::METHOD_POST)
             ->addElements(array(
                 new Zend_Form_Element_Text('name', array(
                     'label'      => 'Имя',
                     'order'      => 1,
                     'decorators' => $this->getStackDecorators('table', 'elements'),
                     'required'   => true
                 )),
                 new Zend_Form_Element_Text('surname', array(
                     'label'      => 'Фамилия',
                     'order'      => 2,
                     'decorators' => $this->getStackDecorators('table', 'elements')
                 )),
                 new Zftest_Form_Element_Phone('phone', array(
                     'label'      => 'Номер телефона',
                     'decorators' => $this->getStackDecorators('table', 'elements'),
                     'order'      => 3,
                     'validators' => array(new Zftest_Validate_PhoneNumber())
                 )),
                 new Zend_Form_Element_Select('city', array(
                     'label'      => 'Город',
                     'order'      => 4,
                     'decorators' => $this->getStackDecorators('table', 'elements'),
                     'multiOptions' => array(1 => 'СПб', 2 => 'Белгород')
                 )),
                 new Zend_Form_Element_Textarea('comment', array(
                     'order'      => 5,
                     'decorators' => $this->getStackDecorators('table', 'elements')
                 )),
                 new Zend_Form_Element_Submit('submit', array(
                     'label'      => 'Отправить',
                     'order'      => 6,
                     'decorators' => $this->getStackDecorators('table', 'buttons')
                 ))
             ));
        $this->addDisplayGroup(array('name', 'surname', 'phone', 'city'), 'mainInfo', array(
            'legend'     => 'Основная информация',
            'decorators' => array(
                array('Callback', array('callback' => 'Zftest_Form::callbackDecoratorGroup')),
                'FormElements',
            )
        ));
        $this->addDisplayGroup(array('comment'), 'otherInfo', array(
            'legend'     => 'Другая информация',
            'decorators' => array(
                array('Callback', array('callback' => 'Zftest_Form::callbackDecoratorGroup')),
                'FormElements',
            )
        ));

        $this->setDecorators($this->getStackDecorators('table', 'form'));
    }
}